<?php

namespace app\util;

/*
 * 微信小程序类
 */

class WxApp
{
    //appid
    const APPID = 'wx58f76d454b6a6ab5';//wx58f76d454b6a6ab5(AI版的)  wxf03b6b5aaedfa785（粉色版）

    //secret
    const SECRET = '6a17d27da812b399cd71d12cd77a59e6';//6a17d27da812b399cd71d12cd77a59e6(AI版的)  158553c156bab018999a1233cf5e9671（粉色版）

    /*
     * 微信小程序获取access_token
     */
    public static function getAccessToken()
    {
//        $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . self::APPID . '&secret=' . self::SECRET;
//        $result = Utils::curlSSLGet($url);

        $url = 'https://ai.mini.dwkkm.com/message/getAccessToken/';//调用曹宇接口获取保存的token
        $result = Utils::curlGet($url);
        $result = json_decode($result, TRUE);
        $data['access_token'] = $result['data'];
        $data['expires_in'] = 7200;
        $data = json_encode($data);
        return $data;
    }

    /*
     * 微信小程序获取小程序码
     */
    public static function getwxacode($access_token, $postFields)
    {
        $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $access_token;

        $result = Utils::curlSSLPost($url, $postFields);
        return $result;
    }

}